-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option_if_let_else - distinguish pure from impure else expressions #5937
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
5fd410e
to
56cea57
Compare
I like clippy would be more consistent overall if this lint used the logic in |
I'll check |
cd23b40
to
726c15b
Compare
The refactoring ended up being quite large. Don't hesitate if you find some changes unnecessary or if you prefer using different naming. |
726c15b
to
0ad345d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring looks great to me!
94902bf
to
2cc25c3
Compare
2cc25c3
to
8d9d894
Compare
8d9d894
to
1f8d1cb
Compare
1f8d1cb
to
6ba36bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! One NIT left.
For future contributions, it would be great if you could submit multiple commits for changes this big and then squash them right before merging. This makes reviewing way easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else LGTM now
tests/ui/unnecessary_lazy_eval.rs
Outdated
// should lint, bind_instead_of_map doesn't apply | ||
let _: Result<usize, usize> = res.and_then(|x| Err(x)); | ||
let _: Result<usize, usize> = res.or_else(|err| Ok(err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two cases aren't linted currently. Is the comment just 2 lines too early or is this a FN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the comment is misleading. These are linted neither by bind_instead_of_map nor unnecessary_lazy_eval (because the closure argument is used). I'll make that clear in the comment.
Thanks for all the work on this! @bors r+ |
📌 Commit 79da747 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Thanks for the many review iterations! @flip1995 |
Addresses partially #5821.
changelog: improve the lint
option_if_let_else
. Suggestmap_or
ormap_or_else
based on the else expression purity.